/*
 * PoreTemperatureTimeAsSourceKernel.C
 *
 *  Created on: 2017年7月24日
 *      Author: liuxiao
 */


#include "PoreTemperatureTimeAsSourceKernel.h"
registerMooseObject("TrilobitaApp", PoreTemperatureTimeAsSourceKernel);
template<>
InputParameters validParams<PoreTemperatureTimeAsSourceKernel>()
{
  InputParameters params = validParams<Kernel>();
  params.addClassDescription("Compute heat source kernel ");
  params.addRequiredCoupledVar("temperature", "Coupled Temperature");
  params.addRequiredCoupledVar("pressure", "Coupled Pressure");
  return params;
}

PoreTemperatureTimeAsSourceKernel::PoreTemperatureTimeAsSourceKernel(const InputParameters & parameters) :
  Kernel(parameters),
  _T(coupledValue("temperature")),
  _dT_dt(coupledDot("temperature")),
  _P(coupledValue("pressure")),
  _R(getMaterialProperty<Real>("gas_constant")),
  _porosity(getMaterialProperty<Real>("porosity"))
{

}

Real PoreTemperatureTimeAsSourceKernel::computeQpResidual()
{
//	std::cout << _k[_qp] <<std::endl;
  Real r(0);
  Real ep = 1e-10;
  r =  _P[_qp]*_porosity[_qp]/(_R[_qp]*_T[_qp]*_T[_qp]+ep)*_dT_dt[_qp]*_test[_i][_qp];
  return -r;
}

Real PoreTemperatureTimeAsSourceKernel::computeQpJacobian()
{
  Real jac(0);
  Real ep;
  jac = _test[_i][_qp]*_phi[_j][_qp]*_porosity[_qp]/(_R[_qp]*_T[_qp]*_T[_qp]+ep)*_dT_dt[_qp]*_test[_i][_qp];
  return -jac;
}






